package vivek.project.pocketmoney.stocks.scripts
{
	import flash.data.*;
	import flash.errors.*;
	import vivek.project.pocketmoney.admin.model.AdminDataCache;

	public class StockSqlScripts
	{
		public static const ADD_NEW_STOCKCONTROL:String="INSERT INTO STOCKCONTROL " + "(SC_STOCKNAME,sc_description,sc_stocktype)" + "VALUES (:sc_name,:sc_description,:sc_type)";
		public static const ADD_NEW_STOCKTRANSACTION:String="INSERT INTO STOCKTRANSACTION " + "(st_stockid, st_date,st_quantity, st_price,st_type,st_exchange,st_channelid,st_id,st_brokerage,st_accountid,st_userid) values " + "(:st_stockid, :st_date,:st_quantity, :st_price,:st_type,:st_exchange,:st_channelid,:st_id,:st_brokerage,:st_accountid, :USERID )";
		public static const ADD_STOCK_TO_WATCHLIST:String="update stockcontrol set sc_watchlist=1 where sc_id=:sc_id";
		public static const DELETE_STOCK_CONTROL:String="delete from STOCKCONTROL where  sc_id = :sc_id and  sc_id not in ( select st_stockid from stocktransaction)";
		public static const DELETE_STOCK_PRICE:String="delete from stockpricedetails where  sp_id = :sp_id";
		public static const DELETE_STOCK_TRANSACTION:String="DELETE FROM STOCKTRANSACTION WHERE ST_ID=:st_id";
		public static const INSERT_STOCK_PRICE:String="insert into stockpricedetails (sp_id,sp_bseprice," + "sp_bsepreviousclose,sp_nseprice,sp_nsepreviousclose,sp_bselasttradedtime,sp_nselastupdated) values ( :sp_id,:sp_bseprice," + ":sp_bsepreviousclose,:sp_nseprice,:sp_nsepreviousclose,(strftime('%HH:%MM:%SS','now','localtime')),(strftime('%HH:%MM:%SS','now','localtime')))";
		public static const REMOVE_STOCK_FROM_WATCHLIST:String="update stockcontrol set sc_watchlist=0 where sc_id=:sc_id";
		public static const SELECT_STOCK_LIST:String="select * from stockcontrol order by sc_stockname";
		public static const SELECT_STOCK_PRICES:String="select * from stockpricedetails,stockcontrol where sp_id=sc_id  order by sc_stockname";
		public static const SELECT_STOCK_TRANSACTIONS:String="select * from stockTRANSACTION,STOCKCONTROL,Accountmanager WHERE SC_ID = ST_STOCKID and am_accountid =st_channelid and st_userid in (select userid from selecteduser) order by ST_STOCKID,st_date";
		public static const SELECT_STOCK_TRANSACTIONS_SORTED:String="select * from stockTRANSACTION,STOCKCONTROL,Accountmanager WHERE SC_ID = ST_STOCKID and am_accountid =st_channelid and st_userid  in (select userid from selecteduser)  order by ST_STOCKID,st_date";
		public static const UPDATE_NEW_STOCKCONTROL:String="UPDATE STOCKCONTROL " + " SET SC_STOCKNAME=:sc_name,sc_description=:sc_description,sc_stocktype=:sc_type where sc_id=:sc_id";
		public static const UPDATE_STOCKTRANSACTION:String="UPDATE STOCKTRANSACTION SET " + "st_stockid =:st_stockid, st_date =:st_date,st_quantity=:st_quantity, st_price =:st_price,st_type =:st_type," + "st_exchange=:st_exchange,st_channelid=:st_channelid,st_brokerage=:st_brokerage,st_accountid=:st_accountid " + "WHERE st_id = :transactionid";
	}
}